#!/bin/bash

name=$1
version=$2
URL=$3

# 判断 framework 是否存在
if [[ -f $name/$name.framework ]]; then
	echo "$name/$name.framework Exist"
	exit 0
fi

echo "========"

# 创建临时文件夹
if [[ ! -d framework_download_dir ]]; then
	mkdir framework_download_dir
fi
cd framework_download_dir

# 解压缩 cp 目录
RET=$(curl --fail -O -v $URL)
if [[ -f $name-$version.zip && ! $RET ]]; then
	unzip $name-$version.zip
	cp -R $name.framework ../
fi

# 移除临时文件目录
cd ..
rm -rf framework_download_dir
